<template>
	<view class="repair-wrap">
		<viewData :type="'noData'" :nextPage="!nextPage" :isTab="false" :isData="repairList.length < 1" :loading="loading"
				  @onRefresh="onRefresh">
			<view style="padding:0 20rpx;">
				<view class="bor_None" v-if="repairList.length == 0">
					<view class="bor_Noneone">
						<image class="bor_Noneimage" src="../../static/image/9015d0e9f45344c4007d408cd271f6a.png" mode=""></image>
					</view>
				</view>
				<view class="u-m-t-20 repair-box rounded-2 shadow" style="padding: 15px 20px;" v-for="(item,index) in repairList" @click="datails('/pages/community/preview',item)">
					<view class="repair-titel u-m-b-20">
						<view style="display: flex;align-items: center;">
							<img style="width: 22px;height: 22px;padding-right: 4px;" src="../../static/image/community2.png" alt="">
							<h3 style="margin-left: 6rpx;">{{item.file_title}}</h3>
						</view>
					</view>
					<view style="color: #999999;margin-top: 5px;font-size: 16px;">
						<view>
							资料说明：
							<span style="color: #000000;">{{item.file_text}}</span>
						</view>
					</view>
					
				</view>
			</view>
		</viewData>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				repairList:[],
				pageIndex:1,
				loading: false,
				// type: 1,
				nextPage:false,
				listData:[],
				typeName:null,
				areabuildfile_type:null,
			}
		},
		onShow() {
			let _this = this
			if (uni.getStorageSync('phone')) {
				if (uni.getStorageSync('loginFlag')) {
					if (!uni.getStorageSync('hourseList')) {
						// uni.showModal({
						// 	title: '请先进行业主认证',
						// 	showCancel: false,
						// 	confirmText: '确认',
						// 	confirmColor: '#F9A832',
						// 	success: function(res) {
						// 		if (res.confirm) {
						// 			_this.$Router.push({
						// 				path: '/pages/address/address'
						// 			})
						// 		}
						// 	}
						// });
						this.$openInvite()
					} else {
						_this.showFlag = true
						_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
						_this.name = _this.homelist.proName;
						_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' + _this.homelist.roomUnitNumber +'-'+ _this.homelist.roomCode
						_this.getList()
					}
				} else {
					uni.showModal({
						title: '请先实名认证',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								_this.$Router.push({
									path: '/pages/realName/realName'
								})
							}
						}
					});
				}
			} else {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
			}
		},
		onLoad(option) {
			this.typeName = option.typeName
			console.log(this.typeName)
			uni.setNavigationBarTitle({
				title: this.typeName
			});
		},
		methods: {
			onRefresh() {
				if (!this.nextPage) {
					this.pageIndex = this.pageIndex + 1;
					this.getList();
				}
			},
			// 获取列表
			getList() {
				let projectArray = uni.getStorageSync('hourseList');
				let indexs = uni.getStorageSync('hourseNum')
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.loading = false;
				this.$request.api.getGreen({
					pageIndex:this.pageIndex,
					pro_id: uni.getStorageSync('projectItem').proId,
					file_kind_child: this.typeName,
					file_kind:'基建文件',
				}).then(res => {
					if (this.pageIndex == 1) {
						this.repairList = res.data.data.datalist || [];
					} else {
						this.repairList = [...this.repairList, ...res.data.data.datalist];
					}
					// uni.getStorageSync('PopupList', res.data.data.projectList[0])
					console.log(this.repairList)
					this.nextPage = res.data.data.isEndPage
					this.loading = true;
					uni.hideLoading();
					/* this.repairList = res.data.data.datalist
					console.log(this.repairList) */
				})
			},
			// 图片预览
			preview(item) {
				uni.previewImage({
					urls: [item],
					current: 0,
					longPressActions: {
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			datails(url,item) {
				let items = encodeURIComponent(JSON.stringify(item))
				uni.navigateTo({
					url: url + '?item='+ items
				});
			},
			// datails() {
			// 	uni.navigateTo({
			// 		url: '/pages/authentication/datails'
			// 	})
			// },
		}
	}
</script>

<style lang="scss">
	.repair-wrap {
		width: 100%;
		min-height: 100vh;
		height: auto;
		background: #f4f4f4;
		overflow: hidden;

		.repair-box {
			background: #fff;

			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}
	.repair-titel i{
		width: 6px;
		height: 13px;
		background: linear-gradient(180deg, #76D904 0%,#417505 100%);
		border-radius: 4px;
		display: inline-block;
		vertical-align: middle;
		margin-top: 4px;
	}
	.bor_None{
		.bor_Noneone{
			width: 232px;
			height: 242px;
			margin: 110px auto;
			.bor_Noneimage{
				width: 100%;height: 100%;	
			}
		}
		.bor_Nonetext{
			width: 62%;margin: -66px auto;text-align: center;color: #999;
		}
		
	}
</style>
